You are here: Symbol Reference > Dew Namespace > Dew.Math Namespace > Classes > TMtxExpression Class > TMtxExpression Methods > DefineFunction Method > TMtxExpression.DefineFunction Method ([In] string, TExprFunc, int, int, [In] string)
Dew Math for .NET
ContentsIndexHome
PreviousUpNext
TMtxExpression.DefineFunction Method ([In] string, TExprFunc, int, int, [In] string)

Defines new function.

Syntax
C#
Visual Basic
public int DefineFunction([In] string AFunctName, TExprFunc AFuncAddress, int NArguments, int NResults, [In] string Help);
Parameters 
Description 
[In] string AFunctName 
Defines function name. If a function with the same name was already definded, it is redefined and all expressions which contain the symbol AFuncName will be recompiled before the next evaluation. 
TExprFunc AFuncAddress 
 
int NArguments 
Defines number of arguments for function. 
int NResults 
Defines number of arguments, which are treated as results. NResults <= NArguments 
[In] string Help 
Function help text. 

Add factorial function to the function list.

using Dew.Math; using Dew.Math.Units; namespace Dew.Examples() { void Example() { void _Factorial_D (TExprRec Param) { Param.Res.DefineDouble; Param.Res.DoubleValue = Fact(System.Math.Round(Param.Args[0].DoubleValue)); } void Example(TMtxExpression MyParser); { myParser.DefineFunction("fact_double", _Factorial_D, 1, "fact_double(x): factorial function"); } } }
Copyright (c) 1999-2024 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!